/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package td3.Vue;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import td3.Modele.*;
/**
 *
 * @author Mohamed Laaqoud
 */
public class FenetreAccueil1 extends javax.swing.JFrame {
    
    /**
     * Creates new form FenetreAccueil1
     */
    public FenetreAccueil1() {
        initComponents();
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ButtonTypeJeu = new javax.swing.ButtonGroup();
        ButtonTypeJoueurs = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        Morpion = new javax.swing.JRadioButton();
        Puissance4 = new javax.swing.JRadioButton();
        IAvsIA = new javax.swing.JRadioButton();
        HumVsIA = new javax.swing.JRadioButton();
        HumVsHum = new javax.swing.JRadioButton();
        Nom1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        Nom2 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jSeparator3 = new javax.swing.JSeparator();
        jLabel5 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Type de jeu");

        jLabel2.setText("Type de joueurs");

        jButton1.setText("Jouer");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jButton2.setText("Quitter");
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
        });
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        ButtonTypeJeu.add(Morpion);
        Morpion.setText("Morpion");
        Morpion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MorpionActionPerformed(evt);
            }
        });

        ButtonTypeJeu.add(Puissance4);
        Puissance4.setText("Puissance4");

        ButtonTypeJoueurs.add(IAvsIA);
        IAvsIA.setText("IA Vs IA");

        ButtonTypeJoueurs.add(HumVsIA);
        HumVsIA.setText("Humain Vs. IA");
        HumVsIA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                HumVsIAActionPerformed(evt);
            }
        });

        ButtonTypeJoueurs.add(HumVsHum);
        HumVsHum.setText("Humain Vs. Humain");

        jLabel3.setText("Nom du 1er joueur");

        jLabel4.setText("Nom du 2eme joueur");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jLabel5.setText("Bienvenue");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(42, 42, 42)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(IAvsIA, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton1)
                            .addComponent(Nom1))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addGap(18, 18, 18)
                                .addComponent(Nom2, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(2, 2, 2)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButton2)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(HumVsIA)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(HumVsHum)))))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(70, 70, 70)
                        .addComponent(Morpion)
                        .addGap(18, 18, 18)
                        .addComponent(Puissance4)
                        .addGap(0, 0, Short.MAX_VALUE))))
            .addComponent(jSeparator1)
            .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING)
            .addComponent(jSeparator3)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel5)
                .addGap(204, 204, 204))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addGap(28, 28, 28)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(Morpion)
                    .addComponent(Puissance4))
                .addGap(11, 11, 11)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(IAvsIA)
                    .addComponent(HumVsIA)
                    .addComponent(HumVsHum))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(Nom1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Nom2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addGap(28, 28, 28))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void MorpionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MorpionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_MorpionActionPerformed
    
    private void HumVsIAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_HumVsIAActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_HumVsIAActionPerformed
    
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed
    
    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
        System.exit(0);
    }//GEN-LAST:event_jButton2MouseClicked
    
    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
        if(this.Morpion.isSelected()) {
            if(this.IAvsIA.isSelected()){
                Joueur J1 = new JoueurAleatoireMorpion(15,this.Nom1.getText());
                Joueur J2 = new JoueurAleatoireMorpion(2,this.Nom2.getText());
                Jeu j = new JeuDeMorpion(J1,J2);
                FenetrePrincipale f = new FenetrePrincipale(j);
                                f.champ1.setText(this.Nom1.getText());
                                f.champ2.setText(this.Nom2.getText());
                Thread p = new Thread (j);
                p.start();
                this.setVisible(false);
                
            }
            if (this.HumVsIA.isSelected()){
                Joueur J1 = new JoueurHumainMorpion(15,this.Nom1.getText());
                Joueur J2 = new JoueurAleatoireMorpion(2,this.Nom2.getText());
                Jeu j = new JeuDeMorpion(J1,J2);
                FenetrePrincipale f = new FenetrePrincipale(j);
                                f.champ1.setText(this.Nom1.getText());
                                f.champ2.setText(this.Nom2.getText());
//                new Thread (j).start(); 
                Thread p = new Thread (j);
                p.start();
                
                
                
                
            }
            if (this.HumVsHum.isSelected()){
                Joueur J1 = new JoueurHumainMorpion(15,this.Nom1.getText());
                Joueur J2 = new JoueurHumainMorpion(2,this.Nom2.getText());
                Jeu j = new JeuDeMorpion(J1,J2);
                FenetrePrincipale f = new FenetrePrincipale(j);
                                f.champ1.setText(this.Nom1.getText());
                                f.champ2.setText(this.Nom2.getText());
                Thread p = new Thread (j);
                p.start();
                
                
            }
            
        }
        if(this.Puissance4.isSelected()) {
            if(this.IAvsIA.isSelected()){
                Joueur J1 = new JoueurAleatoirePuissance4(15,this.Nom1.getText());
                Joueur J2 = new JoueurAleatoirePuissance4(2,this.Nom2.getText());
                Jeu j = new JeuDePuissance4(J1,J2);
                FenetrePrincipale f = new FenetrePrincipale(j);
                                f.champ1.setText(this.Nom1.getText());
                                f.champ2.setText(this.Nom2.getText());
                Thread p = new Thread (j);
                p.start();
                this.setVisible(false);
            }
            if (this.HumVsIA.isSelected()){
                Joueur J1 = new JoueurHumainPuissance4(15,this.Nom1.getText());
                Joueur J2 = new JoueurAleatoirePuissance4(2,this.Nom2.getText());
                Jeu j = new JeuDePuissance4(J1,J2);
                FenetrePrincipale f = new FenetrePrincipale(j);
                                f.champ1.setText(this.Nom1.getText());
                                f.champ2.setText(this.Nom2.getText());
                
                Thread p = new Thread (j);
                p.start();
                this.setVisible(false);
                
            }
            if (this.HumVsHum.isSelected()){
                Joueur J1 = new JoueurHumainPuissance4(15,this.Nom1.getText());
                Joueur J2 = new JoueurHumainPuissance4(2,this.Nom2.getText());
                Jeu j = new JeuDePuissance4(J1,J2);
                FenetrePrincipale f = new FenetrePrincipale(j);
                f.champ1.setText(this.Nom1.getText());
                f.champ2.setText(this.Nom2.getText());
                Thread p = new Thread (j);
                p.start();
                this.setVisible(false);
                
            }
        }
    }//GEN-LAST:event_jButton1MouseClicked
    
    /**
     * @param args the command line arguments
     */
    //    public static void main(String args[]) {
    //        /* Set the Nimbus look and feel */
    //        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    //        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
    //         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
    //         */
    //        try {
    //            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
    //                if ("Nimbus".equals(info.getName())) {
    //                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
    //                    break;
    //                }
    //            }
    //        } catch (ClassNotFoundException ex) {
    //            java.util.logging.Logger.getLogger(FenetreAccueil1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    //        } catch (InstantiationException ex) {
    //            java.util.logging.Logger.getLogger(FenetreAccueil1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    //        } catch (IllegalAccessException ex) {
    //            java.util.logging.Logger.getLogger(FenetreAccueil1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    //        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
    //            java.util.logging.Logger.getLogger(FenetreAccueil1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    //        }
    //        //</editor-fold>
    //
    //        /* Create and display the form */
    //        java.awt.EventQueue.invokeLater(new Runnable() {
    //            public void run() {
    //                new FenetreAccueil1().setVisible(true);
    //            }
    //        });
    //    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup ButtonTypeJeu;
    private javax.swing.ButtonGroup ButtonTypeJoueurs;
    private javax.swing.JRadioButton HumVsHum;
    private javax.swing.JRadioButton HumVsIA;
    private javax.swing.JRadioButton IAvsIA;
    private javax.swing.JRadioButton Morpion;
    private javax.swing.JTextField Nom1;
    private javax.swing.JTextField Nom2;
    private javax.swing.JRadioButton Puissance4;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    // End of variables declaration//GEN-END:variables
}
